<?php
/**
 * Created by PhpStorm.
 * User: shx
 * Date: 2016/11/16
 * Time: 13:54
 */
namespace App\Models\Tag;

use App\Models\Live\Anchor;

trait AnchorType {
    public function anchor()
    {
        return $this->hasOne('App\Models\Live\Anchor', 'id', 'anchor_id');
    }

    public function bindAnchor($anchor)
    {
        $this->type = 'anchor';
        $anchor_id = $anchor instanceof Anchor ? $anchor->id : $anchor;
        $this->anchor_id = $anchor_id;
        return $this->save();
    }
}